//package com.smrtcold.dev.auth;
//
//import jakarta.servlet.FilterChain;
//import jakarta.servlet.ServletException;
//import jakarta.servlet.http.HttpServletRequest;
//import jakarta.servlet.http.HttpServletResponse;
//import lombok.extern.log4j.Log4j2;
//import org.springframework.stereotype.Component;
//import org.springframework.web.filter.OncePerRequestFilter;
//
//import java.io.IOException;
//
//
//@Log4j2
//@Component
//public class JwtAuthenticationTokenFilter extends OncePerRequestFilter {
//
//    @Override
//    protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException {
//        try {
//            String url=request.getRequestURI();
//            if(url.startsWith("/api/")) {
//                String token = request.getHeader("Authorization");
//                if (null == token ||  "Bearer ".equals(token.trim())) {
//                    err(response, 401);
//                    return;
//                }
//            }
//            filterChain.doFilter(request, response);
//        } catch (IOException e) {
//            e.printStackTrace();
//        } catch (ServletException e) {
//            e.printStackTrace();
//        } catch (Exception e) {
//            e.printStackTrace();
//            err(response, 402);
//            return;
//        }
//    }
//
//    private void err(HttpServletResponse response, int code, String... msg) {
//        try {
//            response.setStatus(code);
//            response.sendError(code, null != msg && msg.length > 0 ? msg[0] : "您的登录信息已失效，请重新登录！");
//        } catch (IOException e) {
//            e.printStackTrace();
//        }
//    }
//
//
//}